import 'package:animal/constant/font.dart';
import 'package:animal/utils/screen_util.dart';
import 'package:animal/widgets/image_widget.dart';
import 'package:flutter/material.dart';

class MessageItem{
  ///普通文本消息
  static Widget textMessage({
    String? text, //文字消息内容
    bool sendUser = true, //是否是自我发送到的，true是、false不是
  }){
    return Container(
      padding: EdgeInsets.symmetric(horizontal: ScreenUtil().L(12),vertical: ScreenUtil().L(13)),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.only(
          topLeft:Radius.circular(ScreenUtil().L(sendUser?12:0)),
          bottomRight:Radius.circular(ScreenUtil().L(12)),
          bottomLeft:Radius.circular(ScreenUtil().L(12)),
          topRight:Radius.circular(ScreenUtil().L(sendUser?0:12)),
        )
      ),
      child:Text(text!,style: KFontConstant.myTextStyle(size: 15)),
    );
  }

  ///图片消息
  static Widget imageMessage({
    String? imageUrl, //图片链接
    bool sendUser = true, //是否是自我发送到的，true是、false不是
  }){
    return Container(
      padding: EdgeInsets.symmetric(horizontal: ScreenUtil().L(12),vertical: ScreenUtil().L(13)),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.only(
          topLeft:Radius.circular(ScreenUtil().L(sendUser?12:0)),
          bottomRight:Radius.circular(ScreenUtil().L(12)),
          bottomLeft:Radius.circular(ScreenUtil().L(12)),
          topRight:Radius.circular(ScreenUtil().L(sendUser?0:12)),
        )
      ),
      child: ImageWidget(
        width: 110,
        height: 110,
        imageUrl: imageUrl!,
        borderRadius: BorderRadius.circular(ScreenUtil().L(12))
      ),
    );
  }

  ///商品消息
  static Widget shopMessage({
    String? imageUrl, //图片链接
    bool sendUser = true, //是否是自我发送到的，true是、false不是
  }){
    return Container(
      padding: EdgeInsets.symmetric(horizontal: ScreenUtil().L(12),vertical: ScreenUtil().L(13)),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.only(
          topLeft:Radius.circular(ScreenUtil().L(sendUser?12:0)),
          bottomRight:Radius.circular(ScreenUtil().L(12)),
          bottomLeft:Radius.circular(ScreenUtil().L(12)),
          topRight:Radius.circular(ScreenUtil().L(sendUser?0:12)),
        )
      ),
      child: ImageWidget(
        width: 110,
        height: 110,
        imageUrl: imageUrl!,
        borderRadius: BorderRadius.circular(ScreenUtil().L(12))
      ),
    );
  }
}